<?php include SYSDIR_VIEW ."/common/header.html";?>

<script type="text/javascript" src="<?php echo SYSDIR_HUIADMIN;?>/lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="<?php echo SYSDIR_HUIADMIN;?>/lib/jquery.validation/1.14.0/jquery.validate.min.js"></script> 
<script type="text/javascript" src="<?php echo SYSDIR_HUIADMIN;?>/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="<?php echo SYSDIR_HUIADMIN;?>/lib/jquery.validation/1.14.0/messages_zh.min.js"></script> 
<script src="http://malsup.github.io/jquery.form.js" type="text/javascript"></script>

<article class="page-container">
	<form class="form form-horizontal" id="form-admin-edit">
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>菜单名称：</label>
		<div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" style="width:200px;" value="<?php echo $info['menu_name'];?>" placeholder="" id="menu_name" name="menu_name">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">访问路径：</label>
		<div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" style="width:200px;" value="<?php echo $info['menu_link'];?>" placeholder="" id="menu_link" name="menu_link">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">级别：</label>
		<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select" name="menu_level" size="1">
				<option value="1">一级</option>
                <option value="2" <?php if($info['menu_level']==2) echo 'selected="selected"';?>>二级</option>
			</select>
			</span> </div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">父级：</label>
		<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select" name="menu_par_id" size="1">
				<option value="0">无</option>
                <?php foreach ($menu_list as $key=>$val):?>
                <?php
                    if ($val['menu_level'] == 1) {
                        $sel = '';
                        if ($info['menu_par_id'] == $val['menu_id']) $sel = 'selected="selected"';
                        echo '<option value="'.$val['menu_id'].'" '.$sel.'>'.$val['menu_name'].'</option>';
                    }
                ?>
                <?php endforeach;?>
			</select>
			</span> </div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">排序值：</label>
		<div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" style="width:200px;" value="<?php echo $info['menu_order'] ? $info['menu_order'] : 0;?>" placeholder="" id="menu_order" name="menu_order">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">是否显示：</label>
		<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select" name="menu_show" size="1">
				<option value="1">显示</option>
                <option value="2" <?php if($info['menu_show']==2) echo 'selected="selected"';?>>隐藏</option>
			</select>
			</span> </div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">所属系统：</label>
		<div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" style="width:200px;" value="<?php echo $info['menu_system'] ? $info['menu_system'] : '管理后台系统';?>" placeholder="" id="menu_system" name="menu_system">
		</div>
	</div>
    <input type="hidden" name="action" value="edit" />
    <input type="hidden" name="menu_id" value="<?php echo $info['menu_id'];?>" />
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>
	</form>
</article>

<script type="text/javascript">
$(function(){
	$("#form-admin-edit").validate({
		rules:{
			menu_name:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
            $(form).ajaxSubmit({
                type: 'post', // 提交方式 get/post
                url: '/admin/manager/menu_edit.php', // 需要提交的 url
                data: {
                    //'title': 'y',
                },
                success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
                    // 此处可对 data 作相关处理
                    if (data == 0) {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.$('.btn-refresh').click();
                        parent.location.reload();
                        parent.layer.close(index);
                    }
                    else {
                        alert('操作失败');
                    }
                }
            });

		}
	});
});
</script> 
<?php include SYSDIR_VIEW ."/common/footer.html";?>
